package com.lx.core.weight.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lx.core.util.DateUtils;
import com.lx.core.weight.entity.dto.WeightUpdateDTO;
import com.lx.core.weight.entity.vo.WeightUpdatePageList;
import com.lx.core.weight.entity.vo.WeightUpdateVO;
import com.lx.core.weight.mapper.WeightUpdateMapper;
import com.lx.core.weight.service.WeightUpdateService;
import org.springframework.stereotype.Service;

@Service
public class WeightUpdateServiceImpl implements WeightUpdateService {
    private final WeightUpdateMapper  weightUpdateMapper;

    public WeightUpdateServiceImpl(WeightUpdateMapper  weightUpdateMapper) {
        this.weightUpdateMapper = weightUpdateMapper;
    }




    @Override
    public WeightUpdateVO page(IPage<WeightUpdateVO> page, WeightUpdateDTO updateDTO) {
        updateDTO.setStartTime(DateUtils.formatStartTime(updateDTO.getStartTime()));
        updateDTO.setEndTime(DateUtils.formatEndTime(updateDTO.getEndTime()));
        IPage<WeightUpdatePageList> pageList = weightUpdateMapper.findWeightUpdatePage(page, updateDTO);
        // 构建返回结果
        WeightUpdateVO result = new WeightUpdateVO();
        result.setRecords(pageList.getRecords());
        result.setTotal(pageList.getTotal());
        result.setSize(pageList.getSize());
        result.setCurrent(pageList.getCurrent());
        result.setPages(pageList.getPages());
        return result;
    }
}
